﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="profile.aspx.vb" Inherits="examquestions.profile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page-header">
        <h2>Your profile</h2>
      </div>
    <br />
    This is the personal data we have on record for you. You can edit your profile 
    by clicking on the button below. Once your profile has been checked by a member 
    of staff, you will be able to access answers to questions.<br />
    <br />
    <div class="table-responsive">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="userID" DataSourceID="SqlDataSource1" Width="100%" class="table table-striped table-hover table-bordered">
        <Columns>
            <asp:BoundField DataField="firstName" HeaderText="First Name" 
                SortExpression="firstName" />
            <asp:BoundField DataField="lastName" HeaderText="Last Name" 
                SortExpression="lastName" />
            <asp:BoundField DataField="author" HeaderText="Username" 
                SortExpression="author" />
            <asp:TemplateField HeaderText="Email">
            <ItemTemplate>
            <a href="http://mailto:<%# Eval("email")%>"/><%# Eval("email")%></a> 
            </ItemTemplate>
            </asp:TemplateField>
            
            
            <asp:CheckBoxField DataField="teacher" HeaderText="Teacher" 
                SortExpression="teacher" />
            <asp:BoundField DataField="school" HeaderText="Educational Institution Name" 
                SortExpression="school" />
            <asp:TemplateField HeaderText="Website">
            <ItemTemplate>
            <a href="<%# Eval("websiteURL")%>"/><%# Eval("websiteURL")%></a> 
            </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="country" HeaderText="Country" 
                SortExpression="country" />
            <asp:TemplateField HeaderText="Photo">
            <ItemTemplate>
            <asp:Image ID="imageRemove" runat="server" ImageUrl='<%# Eval("userPhoto")%>' Height="100px"/> 
            </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT [userID], [firstName], [lastName], [email], [author], [userPhoto], [websiteURL], [school], [country], [teacher] FROM [profile] WHERE ([author] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="author" QueryStringField="author" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
    <a class="btn btn-primary btn-sm" href="editProfile.aspx">
    <i class="fa fa-cog"></i> Edit profile</a>

    <a class="btn btn-primary btn-sm" href="Account/ChangePassword.aspx">
    <i class="fa fa-key"></i> Change password</a>

    <a class="btn btn-success btn-sm" href="newItem.aspx">
    <i class="fa fa-pencil"></i> Add a question</a>
    
    <br />
   <div class="page-header">
        <h2>Your statistics</h2>
      </div>
    <br />
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT * FROM [NumberComments] WHERE ([author] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="author" QueryStringField="author" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:FormView ID="frm_questions" runat="server" 
    DataSourceID="SqlDataSource3">
    <ItemTemplate>You have added <%# Eval("NumQuestions")%> question(s) on this site.</ItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
    ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
    SelectCommand="SELECT * FROM [NumQuestions] WHERE ([author] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="author" QueryStringField="author" 
                Type="String" />
        </SelectParameters>
</asp:SqlDataSource>
    <br />
    <asp:FormView ID="frm_comments" runat="server" DataSourceID="SqlDataSource2">
    <ItemTemplate>You have posted <%# Eval("NumComments")%> comment(s) on this site.</ItemTemplate>
    </asp:FormView>
    <br />
    <br />
</asp:Content>
